package com.witmed.lib_http

import com.tencent.mmkv.MMKV
import okhttp3.Interceptor
import okhttp3.Response
import retrofit2.Retrofit
import java.io.File

class TokenRetrofitImpl:BaseRetrpfitImpl() {
    override fun createRetrofit(): Retrofit? {
        val builder = createOkHttpBuilder()
        builder!!.addInterceptor(object : Interceptor{
            override fun intercept(chain: Interceptor.Chain): Response {
                val request = chain.request()
                val token = MMKV.defaultMMKV().decodeString("token","")
                request.newBuilder().addHeader("token",token)
                return chain.proceed(request)
            }

        })
        return createRetrofit(builder.build())
    }

    override fun readTimeout(): Long {
        return 60
    }

    override fun connectTimeout(): Long {
        return 60
    }

    override fun writeTimeout(): Long {
        return 60
    }
}